<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('订单列表')" />
</head>
<body class="gray-bg">
<input id="orderNo" type="hidden"/>
<input id="customerNo" type="hidden"/>
<input id="modeNo" type="hidden"/>
<input id="salesmanNo" type="hidden"/>
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>订单编号：</label>
                                <input type="text" name="orderNo"/>
                            </li>
                            <li>
                                <label>创建类型：</label>
                                <select name="createType" th:with="type=${@dict.getType('erp_create_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>销售员：</label>
                                <input type="text" name="salesmanNo"/>
                            </li>
                            <li>
                                <label>客户编号：</label>
                                <input type="text" name="customerNo"/>
                            </li>
                            <li>
                                <label>合同编号：</label>
                                <input type="text" name="pactNo"/>
                            </li>
                            <li>
                                <label>生产型号：</label>
                                <input type="text" name="modeNo"/>
                            </li>
                            <li class="select-time">
                                <label>下单时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginOrderTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endOrderTime]"/>
                            </li>
                            <li>
                                <label>订单状态：</label>
                                <select name="orderState" th:with="type=${@dict.getType('erp_order_state')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>工序状态：</label>
                                <select name="processState" th:with="type=${@dict.getType('erp_process_state')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li class="select-time">
                                <label>交货时间：</label>
                                <input type="text" class="time-input" id="startTime2" placeholder="开始时间" name="params[beginDeliveryDate]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime2" placeholder="结束时间" name="params[endDeliveryDate]"/>
                            </li>
                            <li>
                                <label>出货：</label>
                                <select name="shipType" th:with="type=${@dict.getType('erp_ship_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>是否新单：</label>
                                <select name="isNewOrder" th:with="type=${@dict.getType('sys_yes_no')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.addFull()" shiro:hasPermission="erp:erpOrder:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.editFull()" shiro:hasPermission="erp:erpOrder:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="erp:erpOrder:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="erp:erpOrder:export">
                    <i class="fa fa-download"></i> 导出
                </a>
                <a class="btn btn-info single disabled" onclick="$.operate.detail()">
                    <i class="fa fa-search"></i> 详细
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('erp:erpOrder:edit')}]];
        var removeFlag = [[${@permission.hasPermi('erp:erpOrder:remove')}]];
        var createTypeDatas = [[${@dict.getType('erp_create_type')}]];
        var orderStateDatas = [[${@dict.getType('erp_order_state')}]];
        var processStateDatas = [[${@dict.getType('erp_process_state')}]];
        var settleWayDatas = [[${@dict.getType('erp_settle_way')}]];
        var receiptStateDatas = [[${@dict.getType('erp_receipt_state')}]];
        var packStyleDatas = [[${@dict.getType('erp_pack_style')}]];
        var shipTypeDatas = [[${@dict.getType('erp_ship_type')}]];
        var isNewOrderDatas = [[${@dict.getType('sys_yes_no')}]];
        var prefix = ctx + "erp/erpOrder";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                detailUrl: prefix + "/detail/{id}",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                clickToSelect: true,
                onClickRow: onClickRow,
                modalName: "订单",
                columns: [{
                    radio: true
                },
                {
                    field: 'id',
                    title: '主键ID',
                    visible: false
                },
                {
                    field: 'orderNo',
                    title: '订单编号'
                },
                {
                    field: 'createType',
                    title: '创建类型',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(createTypeDatas, value);
                    }
                },
                {
                    field: 'salesmanNo',
                    title: '销售员'
                },
                {
                    field: 'customerNo',
                    title: '客户编号'
                },
                {
                    field: 'pactNo',
                    title: '合同编号'
                },
                {
                    field: 'modeNo',
                    title: '生产型号'
                },
                {
                    field: 'pcsNum',
                    title: '下单数量'
                },
                {
                    field: 'prePrice',
                    title: '预报价'
                },
                {
                    field: 'orderPrice',
                    title: '订单金额'
                },
                {
                    field: 'orderTime',
                    title: '下单时间'
                },
                {
                    field: 'orderState',
                    title: '订单状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(orderStateDatas, value);
                    }
                },
                {
                    field: 'processState',
                    title: '工序状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(processStateDatas, value);
                    }
                },
                {
                    field: 'settleWay',
                    title: '结算方式',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(settleWayDatas, value);
                    }
                },
                {
                    field: 'deliveryDate',
                    title: '交货时间'
                },
                {
                    field: 'packStyle',
                    title: '包装方式',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(packStyleDatas, value);
                    }
                },
                {
                    field: 'shipType',
                    title: '出货',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(shipTypeDatas, value);
                    }
                },
                {
                    field: 'isNewOrder',
                    title: '是否新单',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(isNewOrderDatas, value);
                    }
                },
                {
                    field: 'remark',
                    title: '备注'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function onClickRow(row, $element) {
            $("#orderNo").val(row.orderNo);
            $("#customerNo").val(row.customerNo);
            $("#modeNo").val(row.modeNo);
            $("#salesmanNo").val(row.salesmanNo);
        }
    </script>
</body>
</html>